<html>
<head>
	<title>PHP</title>
</head>
<body>
	<script type="text/php">
		class testclass {
			public function testmethod()
			{
				$this->value = 100;
			}
			public function testmethodonearg($one)
			{
				$this->value = $one;
			}
			public function testmethodtwoargs($one, $two)
			{
				$this->value = $one + $two;
			}
		}

		function bind_types($obj)
		{
			$obj->number = 1;
			$obj->str = "string";
			$obj->list = array(1,2,3,4);
			$obj->hash = array("a"=>"b","c"=>"d");
			$obj->object = new testclass();
		};
	</script>


	<!-- Tests for function persistence across script tags -->
	<script type="text/php">
		function across_script_tags2()
		{
			return 24;
		}
		$substance = "donkey poop";
	</script>

	<script>
		function make_substance_ninja_food()
		{
			substance = "ninja food";
		}
	</script>

	<script type="text/php">
		function across_script_tags()
		{
			return across_script_tags2();
		}
		function get_substance()
		{
			global $substance;
			return $substance;
		}
		function modify_substance()
		{
			global $substance;
			global $make_substance_ninja_food;
			$substance = "dinosaur bones";
			$make_substance_ninja_food();
		}
		function get_resources_directory_via_php()
		{
			global $window, $Titanium;
			return $Titanium->Filesystem->getResourcesDirectory();
		}

		function get_include_path()
		{
			return ini_get("include_path");
		}
	</script>

	<script type="text/php">
		include("include.php");
	</script>

	<script>
		function my_global_foo(a)
		{
			return 'you '+a;
		}
		var my_global_var = 'i love you';
	</script>
	
	<div id="a">A</div>
	<script src="php.php" type="text/php"></script>
	<script type="text/php">
		$window->inline_document = function()
		{
			global $window, $document;
			return $document->getElementById('a');
		};
	</script>
	<script>
		window.inline_test_result = inline_document().innerHTML;
		window.external_test_result = external_document().innerHTML;
		window.test_window_global_result = test_window_global();
		window.test_document_title_result = test_document_title();
	</script>
</body>
</html>
